﻿using System;
using System.Configuration;
using mojoPortal.Net;
using mojoPortal.Web;
using Resources;
using mojoPortal.Web.Framework;
using System.Collections;
using mojoPortal.Business;
using ud_gSDMS.Code_Service;
using mojoPortal.Business.WebHelpers;
using System.Linq;
using System.Data;
using Telerik.Web.UI;

namespace ud_gSDMS.Testing
{
    public partial class Project_Test_Detail : mojoBasePage
    {
        private int pageId = -1;
        private int moduleId = -1;
        private int id;
       
        private SiteUser _siteUser;

        void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Send Require";
            //if (!UserCanEditPage() || !UserCanViewPage())
            //{
            //    WebUtils.SetupRedirect(this, SiteRoot + "/AccessDenied.aspx");
            //}


            //SiteUser.ConfirmRegistration()
            //if ( _siteUser == null )
            //{
            //    WebUtils.SetupRedirect(this, SiteRoot + "/AccessDenied.aspx");
            //}
            LoadData();
            //init database
        }

        #region event
        void btnSend_Click(object sender, EventArgs e)
        {
            //ud_gSDMS_PROJECT_TEST temp = null;

            //if (this.LabelEndDateError.Visible || this.LabelStartDateError.Visible)
            //{
            //    this.labelMess.Visible = true;
            //    this.labelMess.Text = "Error!";
            //    return;
            //}
            //try
            //{
            //    temp = gSDMS_BL.ud_gSDMS_PROJECT_TESTs_Upd(
            //        null,
            //        int.Parse(this.radComBBProjectCode.SelectedValue),
            //        this.datCreateDate.SelectedDate,
            //        int.Parse(this.radComBBSender.SelectedValue),
            //        int.Parse(this.radComBBAssignTo.SelectedValue),
            //        this.datStartDate.SelectedDate,
            //        this.datEndDate.SelectedDate,
            //        this.txtNotes.Text,
            //        1,
            //        true
            //        );
            //}
            //catch (Exception ex)
            //{
            //    this.labelMess.Visible = true;
            //    this.labelMess.Text = "Error";
            //}

            //WebUtils.SetupRedirect(this, SiteRoot + "/gsdmsmodule/testing/TManage.aspx?pageid=29");

        }

        #endregion event

        #region OnInit

        protected override void OnPreInit(EventArgs e)
        {
            AllowSkinOverride = true;
            base.OnPreInit(e);
            Load += Page_Load;
        }

        private void LoadData()
        {
            //Load Project code and add to comBBProjectCode
            var projectTest = gSDMS_BL.ud_gSDMS_PROJECT_TEST_Get(id);

            txtProjectCode.Text = projectTest.ud_gSDMS_PROJECT.Code;
            txtCreateDate.Text = projectTest.CreateOn.Value.ToShortDateString(); 
            txtStartDate.Text = projectTest.Start_Date.Value.ToShortDateString();
            txtEndDate.Text = projectTest.End_Date.Value.ToShortDateString();
            txtNotes.Text = projectTest.Notes;
            txtSender.Text = projectTest.mp_User.LoginName;
            txtAssignTo.Text = projectTest.mp_User1.LoginName;

            
        }

        protected override void OnInit(EventArgs e)
        {
            LoadParams();
            LoadPanels();
            base.OnInit(e);
       

            SuppressPageMenu();

                LoadData();
   
        }

        

        private void LoadParams()
        {
            pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, moduleId);
            id = WebUtils.ParseInt32FromQueryString("id", true, id);
        }

        private void LoadPanels()
        {
            bool showLeftColumnAdmin = ConfigHelper.GetBoolProperty("ShowLeftColumnAdmin", false);
            bool showRightColumnAdmin = ConfigHelper.GetBoolProperty("ShowRightColumnAdmin", false);
            bool showTopColumnAdmin = ConfigHelper.GetBoolProperty("ShowTopColumnAdmin", false);
            bool showBottomColumnAdmin = ConfigHelper.GetBoolProperty("ShowBottomColumnAdmin", false);
            int showCenterColumnAdmin = ConfigHelper.GetIntProperty("ShowCenterColumnAdmin", 0);
            LoadSideContent(showLeftColumnAdmin, showRightColumnAdmin, showTopColumnAdmin, showBottomColumnAdmin, showCenterColumnAdmin);
        }
        #endregion
    }
}